/**
 * 
 */
package corp.sunny.sso.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * @File:SSOUserRole.java
 * @Date:Jun 9, 2011
 * @Author:Subhash Bavi
 * 
 * @Description:
 * @Copyright Sunny Corporation - 2011
 */
@Entity
@Table(name = "SUNNY.USRROLE")
public class SSOUserRole implements Serializable {

	private static final long serialVersionUID = -8451536194061353071L;

	private Long id;
	private String roleNm;

	@Id
	@GeneratedValue
	@Column(name = "ROLE_ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "ROLE_NM", nullable = false)
	public String getRoleNm() {
		return roleNm;
	}

	public void setRoleNm(String roleNm) {
		this.roleNm = roleNm;
	}

	@Override
	public boolean equals(Object obj) {
		if (null == obj)
			return Boolean.FALSE;

		if (this == obj)
			return Boolean.TRUE;

		try {
			if (obj instanceof SSOUserRole) {
				SSOUserRole role = (SSOUserRole) obj;
				if ((this.id.longValue() == role.getId().longValue())
						&& (this.roleNm.equals(role.getRoleNm()))) {
					return Boolean.TRUE;
				}
			}
		} catch (Exception e) {
			return Boolean.FALSE;
		}
		return Boolean.FALSE;
	}

	@Override
	public int hashCode() {
		int result = 1;
		final int PRIME = 17;

		if (null != this.roleNm)
			result = result * PRIME
					+ (this.id.hashCode() + this.roleNm.hashCode());
		else
			result = result * PRIME + this.id.hashCode();
		return result;
	}
}
